package com.zhaiweijia.eurekazuul.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.*;

import java.util.ArrayList;

@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {

    /**
     * 拦截器
     */
   /* @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration patterns = registry.addInterceptor(new UrlInterceptor()).addPathPatterns("/**").excludePathPatterns("/*.js").excludePathPatterns("/*.css");
        System.out.println(patterns);
    }*/

    /**
     * 跨域访问
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowCredentials(true)
                .allowedMethods("*")
                .maxAge(3600);
    }
   /* @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").allowedOrigins("*").allowedMethods("GET", "POST", "OPTIONS", "PUT")
                .allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method",
                        "Access-Control-Request-Headers")
                .exposedHeaders("Access-Control-Allow-Origin", "Access-Control-Allow-Credentials")
                .allowCredentials(true).maxAge(3600);
    }*/
}
